function varargout = iCalibrateVert(varargin)
% ICALIBRATEVERT M-file for icalibratevert.fig
%      ICALIBRATEVERT, by itself, creates a new ICALIBRATEVERT or raises the existing
%      singleton*.
%
%      H = ICALIBRATEVERT returns the handle to a new ICALIBRATEVERT or the handle to
%      the existing singleton*.
%
%      ICALIBRATEVERT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ICALIBRATEVERT.M with the given input arguments.
%
%      ICALIBRATEVERT('Property','Value',...) creates a new ICALIBRATEVERT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before icalibratevert_openingfcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to icalibratevert_openingfcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help icalibratevert

% Last Modified by GUIDE v2.5 01-Sep-2013 12:00:02

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @iCalibrateVert_OpeningFcn, ...
                   'gui_OutputFcn',  @iCalibrateVert_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT








function OnOpen(handles)

global inputfile;
global inputfilefull;
global output;
global outputfull;

global fbx; 
global fby; 
global ftx; 
global fty; 
global bbx; 
global bby; 
global btx; 
global bty;

fbx = 0;
fby = 0;
ftx = 0;
fty = 0;
bbx = 0;
bby = 0;
btx = 0;
bty = 0;

savefile = 'videoprocessdata.mat';
load(savefile);

infile = '';

if ~isempty(inputfilefull)
    
    scheck = dir(inputfilefull); 
    
    if ~isempty(scheck)
        infile = inputfilefull;
    end
       
elseif~isempty(inputfile)
    scheck = dir(inputfile);    
    
    if ~isempty(scheck)
        infile = inputfile;
        inputfilefull = inputfile;
    end
end


output = '';
outputfull = '';

if ~isempty(calib2d3dfilefrontvert) && ~isempty(calib2d3dfilefrontvertfull)    
    output = calib2d3dfilefrontvert;
    outputfull = calib2d3dfilefrontvertfull;
end

if ~isempty(infile)
        
    a = strfind(inputfile, '.');
    
    if ~isempty(a) & isempty(output)
        output = strcat(inputfile(1:a-1), '_calibrate_vert.mat');
        outputfull = strcat(pathname, output);  
    end                                                                           
    
    InitVideo(handles);        
end



if ~isempty(outputfull)
    LoadDataFile(outputfull, handles);
end

set(handles.editinput, 'String', inputfile);
set(handles.editdata, 'String', output);


UpdateTextBoxes(handles);







function LoadDataFile(f, handles)

global fbx; 
global fby; 
global ftx; 
global fty; 
global bbx; 
global bby; 
global btx; 
global bty; 

global fdist;
global bdist;

global frontbackdist;

global pfdist;
global pbdist;

global ds;
global dp;

global fpmm;
global bpmm;


scheckfile = dir(f);    

if ~isempty(scheckfile)
    load(f);   
    
    set(handles.editfdist, 'String', num2str(fdist));   %front - distance in mm
    set(handles.editbdist, 'String', num2str(bdist));   %back  - distance in mm

    set(handles.editfrontbackdist, 'String', num2str(frontbackdist));   %front to back distance - mm

    set(handles.editfbx, 'String', num2str(fbx));
    set(handles.editfby, 'String', num2str(fby));
    set(handles.editftx, 'String', num2str(ftx));
    set(handles.editfty, 'String', num2str(fty));
    set(handles.editbbx, 'String', num2str(bbx));
    set(handles.editbby, 'String', num2str(bby));
    set(handles.editbtx, 'String', num2str(btx));
    set(handles.editbty, 'String', num2str(bty));
    
    UpdateTextBoxes(handles);
end   




function InitVideo(handles)

global inputfilefull;
global v;
global totalframes;
global img;
global imgx;
global imgy;



if ~isempty(inputfilefull)

   v = mmreader(inputfilefull);

   totalframes = v.NumberOfFrames;  
   ncurrentframe = 1;
    
   img = read(v,ncurrentframe);         
        
   imshow(img);
        
   sz = size(img);
   imgx = sz(2);
   imgy = sz(1);
   
   set(handles.editframe, 'String', num2str(ncurrentframe));
   set(handles.texttotalframes, 'String', num2str(totalframes));
end



    





function UpdateTextBoxes(handles)

global fbx; 
global fby; 
global ftx; 
global fty; 
global bbx; 
global bby; 
global btx; 
global bty; 

global frontbackdist;

global fdist;
global bdist;

global pfdist;
global pbdist;

global ds;
global dp;

global fpmm;
global bpmm;



fdist = str2double(get(handles.editfdist, 'String'));   %front - distance in mm
bdist = str2double(get(handles.editbdist, 'String'));   %back  - distance in mm

frontbackdist = str2double(get(handles.editfrontbackdist, 'String'));   %front to back distance - mm

fpmm = 0;
bpmm = 0;


fbx = str2double(get(handles.editfbx, 'String'));
fby = str2double(get(handles.editfby, 'String'));
ftx = str2double(get(handles.editftx, 'String'));
fty = str2double(get(handles.editfty, 'String'));
bbx = str2double(get(handles.editbbx, 'String'));
bby = str2double(get(handles.editbby, 'String'));
btx = str2double(get(handles.editbtx, 'String'));
bty = str2double(get(handles.editbty, 'String'));


pfdist = abs(fty-fby);
pbdist = abs(bty-bby);


if fdist > 0
    fpmm = pfdist/fdist;       
end

if bdist > 0
    bpmm = pbdist/bdist;
end


ds = abs(fby-bby)/frontbackdist;
dp = abs(fpmm-bpmm)/frontbackdist;

set(handles.textpfdist, 'String', num2str(pfdist));
set(handles.textpbdist, 'String', num2str(pbdist));

set(handles.textfpmm, 'String', num2str(fpmm));
set(handles.textbpmm, 'String', num2str(bpmm));

set(handles.textds, 'String', num2str(ds));
set(handles.textdp, 'String', num2str(dp));

set(handles.textoutput, 'String', '');




function MouseButtonDown(handles)

global imgx;
global imgy;


point = get(gca,'CurrentPoint');

x = round(point(1,1));
y = round(point(1,2));


fb = get(handles.radiobuttonfb, 'Value');
ft = get(handles.radiobuttonft, 'Value');
bb = get(handles.radiobuttonbb, 'Value');
bt = get(handles.radiobuttonbt, 'Value');

if x > 0 & y > 0 & x <= imgx & y <= imgy
    
    if fb == 1
        fbx = x;
        fby = y;
        
        set(handles.editfbx, 'String', num2str(fbx));
        set(handles.editfby, 'String', num2str(fby));
    elseif ft == 1
        ftx = x;
        fty = y;
                
        set(handles.editftx, 'String', num2str(ftx));
        set(handles.editfty, 'String', num2str(fty));
    elseif bb == 1
        bbx = x;
        bby = y;
        
        set(handles.editbbx, 'String', num2str(bbx));
        set(handles.editbby, 'String', num2str(bby));
    elseif bt == 1
        btx = x;
        bty = y;    
        
        set(handles.editbtx, 'String', num2str(btx));
        set(handles.editbty, 'String', num2str(bty));    
    end                   
end

UpdateTextBoxes(handles)
    



function ButtonGotoFrame(handles)

global totalframes; 
global ncurrentframe;
global img;
global v;

scurrentframe = get(handles.editframe, 'String');
n = str2num(scurrentframe);

if n > 0 & n <= totalframes
    ncurrentframe = n;
    
    img = read(v,ncurrentframe);
    imshow(img)
end








% --- Executes just before icalibratevert is made visible.
function iCalibrateVert_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to icalibratevert (see VARARGIN)

% Choose default command line output for icalibratevert
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes icalibratevert wait for user response (see UIRESUME)
% uiwait(handles.figure1);


OnOpen(handles)



% --- Outputs from this function are returned to the command line.
function varargout = iCalibrateVert_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


MouseButtonDown(handles)



function editfdist_Callback(hObject, eventdata, handles)
% hObject    handle to editfdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfdist as text
%        str2double(get(hObject,'String')) returns contents of editfdist as a double


% --- Executes during object creation, after setting all properties.
function editfdist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editbdist_Callback(hObject, eventdata, handles)
% hObject    handle to editbdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editbdist as text
%        str2double(get(hObject,'String')) returns contents of editbdist as a double


% --- Executes during object creation, after setting all properties.
function editbdist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editbdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editfbpointsdist_Callback(hObject, eventdata, handles)
% hObject    handle to editfbpointsdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfbpointsdist as text
%        str2double(get(hObject,'String')) returns contents of editfbpointsdist as a double


% --- Executes during object creation, after setting all properties.
function editfbpointsdist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfbpointsdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on key press with focus on editfdist and none of its controls.
function editfdist_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to editfdist (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)

UpdateTextBoxes(handles)



% --- Executes on key press with focus on editbdist and none of its controls.
function editbdist_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to editbdist (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)

UpdateTextBoxes(handles)


% --- Executes on key press with focus on editfbpointsdist and none of its controls.
function editfbpointsdist_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to editfbpointsdist (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)



function editfbx_Callback(hObject, eventdata, handles)
% hObject    handle to editfbx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfbx as text
%        str2double(get(hObject,'String')) returns contents of editfbx as a double


% --- Executes during object creation, after setting all properties.
function editfbx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfbx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editfby_Callback(hObject, eventdata, handles)
% hObject    handle to editfby (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfby as text
%        str2double(get(hObject,'String')) returns contents of editfby as a double


% --- Executes during object creation, after setting all properties.
function editfby_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfby (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editftx_Callback(hObject, eventdata, handles)
% hObject    handle to editftx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editftx as text
%        str2double(get(hObject,'String')) returns contents of editftx as a double


% --- Executes during object creation, after setting all properties.
function editftx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editftx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editfty_Callback(hObject, eventdata, handles)
% hObject    handle to editfty (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfty as text
%        str2double(get(hObject,'String')) returns contents of editfty as a double


% --- Executes during object creation, after setting all properties.
function editfty_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfty (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editbbx_Callback(hObject, eventdata, handles)
% hObject    handle to editbbx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editbbx as text
%        str2double(get(hObject,'String')) returns contents of editbbx as a double


% --- Executes during object creation, after setting all properties.
function editbbx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editbbx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editbby_Callback(hObject, eventdata, handles)
% hObject    handle to editbby (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editbby as text
%        str2double(get(hObject,'String')) returns contents of editbby as a double


% --- Executes during object creation, after setting all properties.
function editbby_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editbby (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editbtx_Callback(hObject, eventdata, handles)
% hObject    handle to editbtx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editbtx as text
%        str2double(get(hObject,'String')) returns contents of editbtx as a double


% --- Executes during object creation, after setting all properties.
function editbtx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editbtx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editbty_Callback(hObject, eventdata, handles)
% hObject    handle to editbty (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editbty as text
%        str2double(get(hObject,'String')) returns contents of editbty as a double


% --- Executes during object creation, after setting all properties.
function editbty_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editbty (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editfalx_Callback(hObject, eventdata, handles)
% hObject    handle to editfalx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfalx as text
%        str2double(get(hObject,'String')) returns contents of editfalx as a double


% --- Executes during object creation, after setting all properties.
function editfalx_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfalx (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editfaly_Callback(hObject, eventdata, handles)
% hObject    handle to editfaly (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfaly as text
%        str2double(get(hObject,'String')) returns contents of editfaly as a double


% --- Executes during object creation, after setting all properties.
function editfaly_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfaly (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editfrontbackdist_Callback(hObject, eventdata, handles)
% hObject    handle to editfrontbackdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editfrontbackdist as text
%        str2double(get(hObject,'String')) returns contents of editfrontbackdist as a double


% --- Executes during object creation, after setting all properties.
function editfrontbackdist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editfrontbackdist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbuttonsave.
function pushbuttonsave_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonsave (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


global fbx; 
global fby; 
global ftx; 
global fty; 
global bbx; 
global bby; 
global btx; 
global bty; 

global fdist;
global bdist;

global frontbackdist;

global pfdist;
global pbdist;

global ds;
global dp;

global fpmm;
global bpmm;

global outputfull;

outputfull = get(handles.editdata, 'String');

if ~isempty(outputfull) 
    save(outputfull, 'fbx', 'fby', 'ftx', 'fty', 'bbx', 'bby', 'btx', 'bty',...
     'frontbackdist', 'pfdist', 'pbdist', 'ds', 'dp', 'fdist',... 
     'bdist', 'fpmm', 'bpmm');
 
    set(handles.textoutput, 'String', 'Data saved to file'); 
end


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

UpdateTextBoxes(handles);



function editinput_Callback(hObject, eventdata, handles)
% hObject    handle to editinput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editinput as text
%        str2double(get(hObject,'String')) returns contents of editinput as a double


% --- Executes during object creation, after setting all properties.
function editinput_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editinput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function editdata_Callback(hObject, eventdata, handles)
% hObject    handle to editdata (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editdata as text
%        str2double(get(hObject,'String')) returns contents of editdata as a double


% --- Executes during object creation, after setting all properties.
function editdata_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editdata (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbuttoninput.
function pushbuttoninput_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttoninput (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


global inputfile;
global inputfilefull;


[filename, pathname] = uigetfile( ...
{'*.avi; *.mpg; *.mpeg','Video Files (*.avi, *.mpg, *.mpeg)';   
 '*.*',  'All Files (*.*)'}, ...
 'Pick a file');

if filename ~= 0
    inputfile = filename;
    inputfilefull = strcat(pathname, filename);   
end

set(handles.editinput, 'String', inputfile);

InitVideo(handles);
UpdateTextBoxes(handles);


% --- Executes on button press in pushbuttondata.
function pushbuttondata_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttondata (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global output;
global outputfull;

[filename, pathname] = uigetfile( ...
{'*.mat','Matlab Data Files (*.mat)';   
 '*.*',  'All Files (*.*)'}, ...
 'Pick a file');

if filename ~= 0
    output = filename;
    outputfull = strcat(pathname, filename);   
end

set(handles.editsidedata, 'String', output);



function editframe_Callback(hObject, eventdata, handles)
% hObject    handle to editframe (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of editframe as text
%        str2double(get(hObject,'String')) returns contents of editframe as a double


% --- Executes during object creation, after setting all properties.
function editframe_CreateFcn(hObject, eventdata, handles)
% hObject    handle to editframe (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbuttongoframe.
function pushbuttongoframe_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttongoframe (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

ButtonGotoFrame(handles);
